using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>

    public class LOAIHANGInfo
    {
        #region Local Variable
        public enum Field
        {
            MAHANG,
            LOCATION,
            NHOMHANG,
            TENHANG,
            DVTINH,
            QUYCACH,
            GHICHU,
            NOTVAT
        }
        private String _MAHANG;
        private String _LOCATION;
        private String _NHOMHANG;
        private String _TENHANG;
        private String _DVTINH;
        private String _QUYCACH;
        private String _GHICHU;
        private bool _NOTVAT;

        public String MAHANG { get { return _MAHANG; } set { _MAHANG = value; } }
        public String LOCATION { get { return _LOCATION; } set { _LOCATION = value; } }
        public String NHOMHANG { get { return _NHOMHANG; } set { _NHOMHANG = value; } }
        public String TENHANG { get { return _TENHANG; } set { _TENHANG = value; } }
        public String DVTINH { get { return _DVTINH; } set { _DVTINH = value; } }
        public String QUYCACH { get { return _QUYCACH; } set { _QUYCACH = value; } }
        public String GHICHU { get { return _GHICHU; } set { _GHICHU = value; } }
        public bool NOTVAT { get { return _NOTVAT; } set { _NOTVAT = value; } }

        #endregion LocalVariable

        #region Constructor
        public LOAIHANGInfo()
        {
            _MAHANG = "";
            _LOCATION = "";
            _NHOMHANG = "";
            _TENHANG = "";
            _DVTINH = "";
            _QUYCACH = "";
            _GHICHU = "";
            _NOTVAT = false;
        }
        public LOAIHANGInfo(
        String MAHANG,
        String LOCATION,
        String NHOMHANG,
        String TENHANG,
        String DVTINH,
        String QUYCACH,
        String GHICHU,
            bool NOTVAT
        )
        {
            _MAHANG = MAHANG;
            _LOCATION = LOCATION;
            _NHOMHANG = NHOMHANG;
            _TENHANG = TENHANG;
            _DVTINH = DVTINH;
            _QUYCACH = QUYCACH;
            _GHICHU = GHICHU;
            _NOTVAT = NOTVAT;
        }
        public LOAIHANGInfo(DataRow dr)
        {
            if (dr != null)
            {
                _MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MAHANG.ToString()]);
                _LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LOCATION.ToString()]);
                _NHOMHANG = dr[Field.NHOMHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.NHOMHANG.ToString()]);
                _TENHANG = dr[Field.TENHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.TENHANG.ToString()]);
                _DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DVTINH.ToString()]);
                _QUYCACH = dr[Field.QUYCACH.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.QUYCACH.ToString()]);
                _GHICHU = dr[Field.GHICHU.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.GHICHU.ToString()]);
                _NOTVAT = dr[Field.NOTVAT.ToString()] == DBNull.Value ? false : Convert.ToBoolean(dr[Field.NOTVAT.ToString()]);
            }
        }
        public LOAIHANGInfo(DataRowView dr)
        {
            if (dr != null)
            {
                _MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MAHANG.ToString()]);
                _LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LOCATION.ToString()]);
                _NHOMHANG = dr[Field.NHOMHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.NHOMHANG.ToString()]);
                _TENHANG = dr[Field.TENHANG.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.TENHANG.ToString()]);
                _DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DVTINH.ToString()]);
                _QUYCACH = dr[Field.QUYCACH.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.QUYCACH.ToString()]);
                _GHICHU = dr[Field.GHICHU.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.GHICHU.ToString()]);
                _NOTVAT = dr[Field.NOTVAT.ToString()] == DBNull.Value ? false : Convert.ToBoolean(dr[Field.NOTVAT.ToString()]);
            }
        }
        public LOAIHANGInfo(LOAIHANGInfo objEntr)
        {
            _MAHANG = objEntr.MAHANG;
            _LOCATION = objEntr.LOCATION;
            _NHOMHANG = objEntr.NHOMHANG;
            _TENHANG = objEntr.TENHANG;
            _DVTINH = objEntr.DVTINH;
            _QUYCACH = objEntr.QUYCACH;
            _GHICHU = objEntr.GHICHU;
            _NOTVAT = objEntr.NOTVAT;
        }
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("LOAIHANG");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.MAHANG.ToString(), typeof(String)),
				new DataColumn(Field.LOCATION.ToString(), typeof(String)),
				new DataColumn(Field.NHOMHANG.ToString(), typeof(String)),
				new DataColumn(Field.TENHANG.ToString(), typeof(String)),
				new DataColumn(Field.DVTINH.ToString(), typeof(String)),
				new DataColumn(Field.QUYCACH.ToString(), typeof(String)),
				new DataColumn(Field.GHICHU.ToString(), typeof(String)),
				new DataColumn(Field.NOTVAT.ToString(), typeof(bool))
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.MAHANG.ToString()] = _MAHANG;
            row[Field.LOCATION.ToString()] = _LOCATION;
            row[Field.NHOMHANG.ToString()] = _NHOMHANG;
            row[Field.TENHANG.ToString()] = _TENHANG;
            row[Field.DVTINH.ToString()] = _DVTINH;
            row[Field.QUYCACH.ToString()] = _QUYCACH;
            row[Field.GHICHU.ToString()] = _GHICHU;
            row[Field.NOTVAT.ToString()] = _NOTVAT;
            return row;
        }
        #endregion InitTable
    }
}
